package com.hspedu.newData.dmsxl.数组.前缀和;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-06 
 * @Version: 1.0
 */

public class LC1732找到最高海拔 {

    public int largestAltitude(int[] gain) {
        int len = gain.length;
        int max = gain[0] > 0 ? gain[0] : 0;
        for (int i = 1; i < len; i++) {
            gain[i] = gain[i-1] + gain[i];
            if (max < gain[i]){
                max = gain[i];
            }
        }
        return max;
    }

    @Test
    public void test() {
        // 测试代码

        largestAltitude(new int[]{});
    }
}
